package com.sx.epidemic_system.controller;

import com.sx.epidemic_system.entity.*;
import com.sx.epidemic_system.service.NewAddService;
import com.sx.epidemic_system.service.NowPatientService;
import com.sx.epidemic_system.service.PatientService;
import com.sx.epidemic_system.service.TotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class PatientController
{
    @Autowired
    private PatientService patientService;
    @Autowired
    private NowPatientService nowPatientService;
    @Autowired
    private TotalService totalService;
    @Autowired
    private NewAddService newAddService;
//    跳转页面后的新数据
    @ResponseBody
    @RequestMapping("/getHrefData")
    public List<Integer>getHrefData(String province)
    {

        List<Integer>list=new ArrayList<>();
        list.add(newAddService.getAllNewAddProvince(province));
        list.add(newAddService.getContinentNewAddProvince(province));
        list.add(newAddService.getOutSideNewAddProvince(province));
        list.add(newAddService.getAsymptomaticProvince(province));
        list.add(nowPatientService.getNowPvCon(province));
        list.add(totalService.totalCount(province).getTotalConfirm());
        list.add(totalService.totalCure(province).getTotalConfirm());
        list.add(totalService.totalDead(province).getTotalConfirm());
        return list;
    }
//    获取map地图所需要的数据<name,value>
    @ResponseBody
    @RequestMapping("/getMapData")
    public List<MapValue> getMapData(){
        return patientService.queryMapRes();
    }
    //    获取map地图所需要的数据<name,value>-新增
    @ResponseBody
    @RequestMapping("/getMapNewAddData")
    public List<MapValue> getMapNewAddData(){
        return patientService.queryMapsNewAdd();
    }
//    获取现有确诊
    @ResponseBody
    @RequestMapping("/getCountNum")
    public int getCountNum(){
        return patientService.getCountNum();
    }
//    获取无症状患者 typ=2
    @ResponseBody
    @RequestMapping("/getType2Num")
    public int getType2Num(){
        return patientService.getType2Num();
    }

    //    获取按时间分组增长
    @ResponseBody
    @RequestMapping("/getGruopPatientNumByTimeOutside")
    public List<ChartsValue> getGruopPatientNumByTimeOutside()  {
        return patientService.getGruopPatientNumByTimeOutside();
    }
    //    获取国内按时间分组增长
    @ResponseBody
    @RequestMapping("/getGruopPatientNumByTime")
    public List<ChartsValue> getGruopPatientNumByTime(@RequestParam(value = "province",required = false) String provience)  {
        return patientService.getGruopPatientNumByTime(provience);
    }

    //    获取省份境外累计输入
    @ResponseBody
    @RequestMapping("/getProAndOutNum")
    public List<Histogram> getProAndOutNum(){
        return patientService.getProAndOutNum();
    }


    //    获取(某省份)新增无症状数量按按时间分组
    @ResponseBody
    @RequestMapping("/getProWzzNumGroupBytime")
    public List<ChartsValue> getProWzzNumGroupBytime(String province){
        return  patientService.getProWzzNumGroupBytime(province);
    }
    //    获取（某省份）新增确诊数量时间按时间分组
    @ResponseBody
    @RequestMapping("/getProSureGroupBytime")
    public List<ChartsValue> getProSureGroupBytime(String province){
        return patientService.getProSureGroupBytime(province);
    }
    //    获取某省份确诊/治愈/死亡人数
    @ResponseBody
    @RequestMapping("/getProCSDNum")
    public List<LinesChartsValue> getProCSDNum(String province){
        return patientService.getProCSDNum(province);
    }
}
